1   /*
2    * Copyright (C) 2008 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.google.common.collect.testing;
18  
19  import static com.google.common.collect.testing.Helpers.orderEntriesByKey;
20  
21  import com.google.common.annotations.GwtCompatible;
22  
23  import java.util.List;
24  import java.util.Map.Entry;
25  import java.util.SortedMap;
26  
27  /**
28   * Implementation helper for {@link TestMapGenerator} for use with sorted maps of strings.
29   *
30   * @author Chris Povirk
31   */
32  @GwtCompatible
33  public abstract class TestStringSortedMapGenerator extends TestStringMapGenerator 
34      implements TestSortedMapGenerator<String, String> {
35    @Override
36    public Entry<String, String> belowSamplesLesser() {
37      return Helpers.mapEntry("!! a", "below view");
38    }
39  
40    @Override
41    public Entry<String, String> belowSamplesGreater() {
42      return Helpers.mapEntry("!! b", "below view");
43    }
44  
45    @Override
46    public Entry<String, String> aboveSamplesLesser() {
47      return Helpers.mapEntry("~~ a", "above view");
48    }
49  
50    @Override
51    public Entry<String, String> aboveSamplesGreater() {
52      return Helpers.mapEntry("~~ b", "above view");
53    }
54  
55    @Override
56    public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) {
57      return orderEntriesByKey(insertionOrder);
58    }
59  
60    @Override
61    protected abstract SortedMap<String, String> create(Entry<String, String>[] entries);
62    
63    @Override
64    public SortedMap<String, String> create(Object... entries) {
65      return (SortedMap<String, String>) super.create(entries);
66    }
67  }